/**
 * Package: Threading
 */

#define TI_THREADNUM 0
#define TI_STACKSIZE 1
#define TI_CYCLES    2

/// <summary>A new thread gets started. Every function in the program can be used as starting function for the thread.</summary>
/// <param name="thread">Thread number (0-13).</param>
/// <param name="func">Function name of the function where the thread will be started.</param>
void Thread_Start           $opc(0x35)(byte thread, float func);

/// <summary>Terminates a thread. If 0 is given as thread number, the whole program will be terminated.</summary>
/// <param name="thread">Thread number (0-13).</param>
void Thread_Kill            $opc(0x36)(byte thread);

/// <summary>A thread will set to "sleep" for a specified time. After this time the thread is again ready for execution. The waiting period is given in ticks that are created by Timer 2. If Timer 2 is set off or used for other purposes, the mode of operation of Thread_Delay() is not defined.</summary>
/// <param name="delay">Number of 10ms ticks that should be waited.</param>
void Thread_Delay           $opc(0x40)(word delay);

/// <summary>Inhibits thread changes. This is reasonable if you have a series of port operations or other hardware actions that should not timely be separated in a thread change.</summary>
/// <param name="lock">If set to 1 thread changes are inhibited, 0 means thread changes are allowed.</param>
void Thread_Lock            $opc(0x41)(byte lock);

/// <summary>The thread gets the state "waiting". The state can be changed back to "inactive" with calls to Thread_Resume() or Thread_Signal().</summary>
/// <param name="thread">Thread number (0-13).</param>
/// <param name="signal">Signal value.</param>
void Thread_Wait            $opc(0x42)(byte Thread, byte signal);

/// <summary>If a thread has the state "waiting" it can be set to "inactive" with this function call. "Inactive" means that a thread is ready for activation at a thread change.</summary>
/// <param name="thread">Thread number (0-13).</param>
void Thread_Resume          $opc(0x43)(byte thread);

/// <summary>Has a thread been set to state "waiting" with a call to Thread_Wait() it can be set to "inactive" with a call to Thread_Signal(). The signal parameter must have the same value as the value that has been used in the call to Thread_Wait().</summary>
/// <param name="signal">Signal value.</param>
void Thread_Signal          $opc(0x44)(byte signal);

/// <summary>Sets the number of executed bytecode instructions before thread change to the parameter cycles.</summary>
/// <param name="thread">Thread number (0-13).</param>
/// <param name="cycles">Cycle count until thread change.</param>
void Thread_Cycles          $opc(0x45)(byte thread, word cycles);

/// <summary>The function returns information about the calling thread. The info parameter defines what kind of information is returned.</summary>
/// <param name="info">Info values.</param>
/// <returns>Info result.</returns>
word Thread_Info            $opc(0x5E)(byte info);

/// <summary>Returns the free memory that is available for the calling thread.</summary>
/// <returns>Free memory in bytes.</returns>
word Thread_MemFree         $opc(0x5F)(void);